<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *打卡记录
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$tabs=array(
	array('op'=>'list','title'=>'企业签章'),
	array('op'=>'edit','title'=>'添加签章'),
);
if($_RQ['op']=='list'){
	$type=intval($_RQ['type']);
	$params=array('uniacid'=>$_SESSION['uniacid'],'merchid'=>$merchid);
	if(!empty($_RQ['baoid'])){
		$params['baoid']=intval($_RQ['baoid']);
		$return['params']['baoid']=intval($_RQ['baoid']);
	}
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_aihire_qianzhang',$params,array($pindex,$psize),$total,$fields,'','id desc');
	foreach($list as &$item){

	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>true,'list'=>array(
			array('type'=>'radio','title'=>'签章类型','name'=>'type','options'=>'qianzhang_type'),
			array('type'=>'radio','title'=>'签章生成方式','name'=>'uptype','options'=>'uptype'),
			array('name'=>'image','title'=>'企业签章','type'=>'image'),
			array('type'=>'radio','title'=>'是否默认','name'=>'isdefault','options'=>'isradio'),
			array('type'=>'radio','title'=>'骑缝章','name'=>'isqifeng','options'=>'isradio'),
			array('name'=>'createtime','title'=>'时间','type'=>'time'),
		)),
		'search'=>array(
			array('name'=>'title','width'=>15,'title'=>'保单方案','type'=>'string'),
		)
	);
	$return['qianzhang_type']=$this->qianzhang_type;
	$return['uptype']=array('系统生成','本地上传');
	$return['isradio']=array('否','是');
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='edit'){
	if($_RQ['postdata']){
		$postdata=get_postdata();
		$id=$postdata['id'];
		$data=array(
			'type'=>$postdata['type'],
			'uptype'=>$postdata['uptype'],
			'title1'=>trim($postdata['title1']),
			'title2'=>trim($postdata['title2']),
			'image'=>$postdata['image'],
			'isdefault'=>$postdata['isdefault'],
			'isqifeng'=>$postdata['isqifeng'],
		);
		if($id){
			pdo_update('jy_aihire_qianzhang',$data,array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		}else{
			$data['uniacid']=$_SESSION['uniacid'];
			$data['merchid']=$merchid;
			$data['createtime']=time();
			pdo_insert('jy_aihire_qianzhang',$data);
		}
		exi('操作成功','','list');
	}
	$id=$_RQ['id'];
	if($id){
		$item=pdo_get('jy_aihire_qianzhang',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
	}else{
		$item=array(
			'uptype'=>0,
		);
	}
	$return['item']=$item;
	$htmls=array(
			'type'=>'edit',
			'edit'=>array(
				array('type'=>'radio','title'=>'签章类型','name'=>'type','options'=>'qianzhang_type'),
				array('type'=>'radio','title'=>'签章生成方式','name'=>'uptype','options'=>'uptype'),
				array('name'=>'title1','title'=>'请输入签章横向文字','type'=>'string','show'=>array('uptype'=>0)),
				array('name'=>'title2','title'=>'请输入签章下旋文字','type'=>'string','show'=>array('uptype'=>0)),
				array('name'=>'image','title'=>'上传企业签章','type'=>'image','help'=>'要求：仅支持png格式，且背景透明','show'=>array('uptype'=>1)),
				array('type'=>'switch','title'=>'默认页面印章','name'=>'isdefault'),
				array('type'=>'switch','title'=>'是否骑缝章','name'=>'isqifeng'),
			),
	);
	$return['qianzhang_type']=$this->qianzhang_type;
	$return['uptype']=array('系统生成','本地上传');
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='del'){
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
	}else{
		$del=array();
	}
	if($_RQ['id']){
		$del[]=$_RQ['id'];
	}
	foreach($del as $id){
		$id=intval($id);
		if($id){
			pdo_delete('jy_aihire_qianzhang',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		}
	}
	exi('删除成功！');
}
